package com.zzh.mvvm.base.vm;


import android.app.Application;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;

import com.zzh.mvvm.binding.command.BindingCommand;

import androidx.annotation.NonNull;
import androidx.databinding.ObservableField;

/**
 * Created by ZZH on 2022/11/24.
 *
 * @Date: 2022/11/24
 * @Email: zzh_hz@126.com
 * @QQ: 1299234582
 * @Author: zzh
 * @Description:
 */
public class BaseToolbarViewModel<M extends BaseModel> extends BaseViewModel<M> {

    /**
     * Toolbar 背景颜色
     */
    public ObservableField<Drawable> toolbarBackResDrawable = new ObservableField<>(getToolbarBackground());
    /**
     * Toolbar 背景颜色
     */
    public ObservableField<Integer> navigationIcon = new ObservableField<>(navigationIconResId());
    public ObservableField<CharSequence> toolbarTitleText = new ObservableField<>(getToolbarTitle());

    protected CharSequence getToolbarTitle() {
        return "";
    }


    public BaseToolbarViewModel(Application application) {
        super(application);
    }

    public BaseToolbarViewModel(@NonNull Application application, M model) {
        super(application, model);
    }

    /**
     * Toolbar 背景颜色
     *
     * @return 颜色值
     */
    protected Drawable getToolbarBackground() {
        return new ColorDrawable(Color.WHITE);
    }

    public int navigationIconResId() {
        return android.R.drawable.arrow_up_float;
    }

    public BindingCommand clickBackCommand = new BindingCommand(o -> finish());
}
